package org.simplecrm.domain.user;

import org.simplecrm.domain.usergroup.UserGroup;

import java.io.Serializable;

/**
 * User entity.
 */
public class User implements Serializable {

    private Integer id;
    private String login;
    private String password;
    private UserGroup usergroup;

    public User() {
    }

    public User(Integer id, String login, String password, UserGroup userGroup) {
        setId(id);
        setLogin(login);
        setPassword(password);
        setUsergroup(userGroup);
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public UserGroup getUsergroup() {
        return usergroup;
    }

    public void setUsergroup(UserGroup usergroup) {
        this.usergroup = usergroup;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof User)) {
            return false;
        }

        User user = (User) o;

        if (!id.equals(user.id)) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        return id.hashCode();
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", login='" + login + '\'' +
                ", password='" + password + '\'' +
                ", usergroup=" + usergroup +
                '}';
    }
}
